﻿using UnityEngine;
using UnityEngine.UI;

namespace Jinndev {

    public class DebugUIRaycast : MonoBehaviour {

#if UNITY_EDITOR
        static Vector3[] fourCorners = new Vector3[4];
        public Color color = Color.green;

        void OnDrawGizmos() {
            foreach (MaskableGraphic g in GameObject.FindObjectsOfType<MaskableGraphic>()) {
                if (g.raycastTarget) {
                    RectTransform rectTransform = g.transform as RectTransform;
                    rectTransform.GetWorldCorners(fourCorners);
                    Gizmos.color = color;
                    for (int i = 0; i < 4; i++) {
                        Gizmos.DrawLine(fourCorners[i], fourCorners[(i + 1) % 4]);
                    }
                }
            }
        }
#endif

    }

}
